package tst

class A
{
	def static apply(self, Closure closure)
	{
//		Class clazz;
//		clazz.superclass
		println "self:${self.toString()},superclass:${self.getClass().superclass.name}"
		return self.with(closure)
	}
}

class B
{
	static Closure rule= {
		println 'B'
		delegate.apply(C.rule)
	}
}

class C
{
	static Closure rule= {
		println 'C'
		delegate.apply(D.rule)
	}
}

class D
{
	static Closure rule= {
		println "D,variables:${var}"
		ret = 'success'
	}
}

var = 'helloworld'

use(A)
{
	delegate.apply(B.rule);
	println ret;
	println this.binding.variables;
}

